POV-Ray : Newsgroups : povray.advanced-users : #write(outfile,chr(0)) doesn't work. A bug? : Re: #write(outfile,chr(0)) doesn't work. A bug? Server Time
30 Jul 2024 08:15:17 EDT (-0400)
  Re: #write(outfile,chr(0)) doesn't work. A bug?  
From: Gerald K  Dobiasovsky
Date: 21 Oct 1999 15:49:49
Message: <380f6e5d@news.povray.org>
Nieminen Juha <war### [at] punarastascstutfi> wrote:
>   I was trying to make a pov script which could create its own .df3 file.
> However, this seems to be impossible since for some reason povray refuses
> to write the value 0 to the file. Every other value (1-255) can be written
> but not 0.
>   What's going on here? Is it a bug or an intentional feature?
>

Under DOS it also happily expands chr(10) to 13 and 10 for obvious
reasons - this is text output after all...

There's a function Parse_Write() in tokenize.c
which calls Parse_Formatted_String() in express.c.
Even a single character is represented as a whole string internally,
so chr(0) is not written because it's interpreted as end-of-string.

BTW I found another bug in the above function.
Try a string ending with '\\' either in a file write or in one of the
console output streams:
Most of the time one gets garbage appended to the string,
because the pointer to the last character in the source string is
incremented even if this character is the null-byte.


Gerald
ger### [at] aonat


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.